home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-05-04 | 1.6 KB | 35 lines | [TEXT/GEOL] |
- Item 7219558 28-April-90 20:27PDT
-
- From: MIKE.VILOT ObjectWare, Michael Vilot,PRT
-
- To: D0532 Aidea Systems, Don Park,PRT
-
- cc: CPLUS.DEV$ C++ Interest List--Developers
- CPLUS.APPLE$ C++ Interest List--Apple Employees
-
- Sub: Re: Handling Constructor…
-
- Well, I'll bypass the obvious questions regarding your need to use
- malloc/free over either new/delete or Mac Toolbox calls ...
-
- One of the nice aspects of having objects to work with is that they
- maintain state. That is, they can ``remember'' has has (or has not)
- happened to them. In your example, it is not necessary to require clients
- manually invoke a Validate function, since the semantics of it can be
- internal to the DoSomething function.
- That is, the object can have an additional member to record whatever
- status you would like to maintain about the validity or integrity of
- the object. The object's member functions would consult it before doing
- anything, and basically take no action if the object was not in a healthy
- state.
- The case of allocating dynamic objects is more interesting. Take a
- look at the header file ``new.h'' and the function set_new_handler. By
- default, operator new returns NULL if it fails to retain the behavior of
- malloc(). However, it does this only if the function pointer _new_handler
- is NULL (the default). You can use set_new_handler() to a function of
- your choosing. That way, you will be notified if operator new ever fails.
-
- Hope this helps,
- Mike
-
-